package com.iyundao.io.mapper;

import com.iyundao.io.model.RoleMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

@Repository
public interface RoleMenuMapper {
    @Delete({
        "delete from role_menu",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(String sid);

    @Insert({
        "insert into role_menu (sid, rid, mid)",
        "values (#{sid,jdbcType=CHAR}, #{rid,jdbcType=CHAR}, #{mid,jdbcType=CHAR})"
    })
    int insert(RoleMenu record);

    @InsertProvider(type=RoleMenuSqlProvider.class, method="insertSelective")
    int insertSelective(RoleMenu record);

    @Select({
        "select",
        "sid, rid, mid",
        "from role_menu",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    @Results({
        @Result(column="sid", property="sid", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="rid", property="rid", jdbcType=JdbcType.CHAR),
        @Result(column="mid", property="mid", jdbcType=JdbcType.CHAR)
    })
    RoleMenu selectByPrimaryKey(String sid);

    @UpdateProvider(type=RoleMenuSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(RoleMenu record);

    @Update({
        "update role_menu",
        "set rid = #{rid,jdbcType=CHAR},",
          "mid = #{mid,jdbcType=CHAR}",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(RoleMenu record);
}